[damned-lies] Fix sample_data fixture and add method to create fixtures
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fix sample_data fixture and add method to create fixtures
- Date: Sat, 27 Nov 2010 14:02:15 +0000 (UTC)
commit 7ae5124946cfc9f78bd633fc30265168d26c01f3
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Nov 27 15:01:27 2010 +0100
Fix sample_data fixture and add method to create fixtures
stats/fixtures/sample_data.json | 636 ++++++++++++++++++++-------------------
stats/tests/__init__.py | 2 +
stats/tests/fixture_factory.py | 163 ++++++++++
3 files changed, 498 insertions(+), 303 deletions(-)
---
diff --git a/stats/fixtures/sample_data.json b/stats/fixtures/sample_data.json
index 93cc2a5..f42143d 100644
--- a/stats/fixtures/sample_data.json
+++ b/stats/fixtures/sample_data.json
@@ -1,20 +1,98 @@
[
{
"pk": 1,
- "model": "sites.site",
+ "model": "auth.user",
+ "fields": {
+ "username": "bob",
+ "first_name": "Robert",
+ "last_name": "Translator",
+ "is_active": true,
+ "is_superuser": false,
+ "is_staff": false,
+ "last_login": "2010-11-23 12:08:32",
+ "groups": [],
+ "user_permissions": [],
+ "password": "!",
+ "email": "bob example org",
+ "date_joined": "2010-11-23 12:08:32"
+ }
+ },
+ {
+ "pk": 2,
+ "model": "auth.user",
+ "fields": {
+ "username": "coord",
+ "first_name": "John",
+ "last_name": "Coordinator",
+ "is_active": true,
+ "is_superuser": false,
+ "is_staff": false,
+ "last_login": "2010-11-23 12:08:32",
+ "groups": [],
+ "user_permissions": [],
+ "password": "!",
+ "email": "coord example org",
+ "date_joined": "2010-11-23 12:08:32"
+ }
+ },
+ {
+ "pk": 3,
+ "model": "auth.user",
"fields": {
- "domain": "localhost:8000",
- "name": "localhost:8000"
+ "username": "alessio",
+ "first_name": "Alessio",
+ "last_name": "Reviewer",
+ "is_active": true,
+ "is_superuser": false,
+ "is_staff": false,
+ "last_login": "2010-11-23 12:08:32",
+ "groups": [],
+ "user_permissions": [],
+ "password": "!",
+ "email": "alessio example org",
+ "date_joined": "2010-11-23 12:08:32"
+ }
+ },
+ {
+ "pk": 3,
+ "model": "people.person",
+ "fields": {
+ "bugzilla_account": null,
+ "groups": [],
+ "image": null,
+ "activation_key": null,
+ "irc_nick": null,
+ "svn_account": null,
+ "webpage_url": null,
+ "user_permissions": []
}
- },
+ },
{
"pk": 1,
- "model": "languages.language",
+ "model": "people.person",
"fields": {
- "locale": "en",
- "plurals": "nplurals=2; plural=(n != 1)",
- "name": "en",
- "team": null
+ "bugzilla_account": null,
+ "groups": [],
+ "image": null,
+ "activation_key": null,
+ "irc_nick": "bobby",
+ "svn_account": "bob1",
+ "webpage_url": null,
+ "user_permissions": []
+ }
+ },
+ {
+ "pk": 2,
+ "model": "people.person",
+ "fields": {
+ "bugzilla_account": null,
+ "groups": [],
+ "image": null,
+ "activation_key": null,
+ "irc_nick": null,
+ "svn_account": "coord_fr",
+ "webpage_url": null,
+ "user_permissions": []
}
},
{
@@ -39,23 +117,86 @@
},
{
"pk": 1,
+ "model": "languages.language",
+ "fields": {
+ "locale": "en",
+ "plurals": "nplurals=2; plural=(n != 1)",
+ "name": "en",
+ "team": null
+ }
+ },
+ {
+ "pk": 1,
+ "model": "teams.team",
+ "fields": {
+ "mailing_list_subscribe": "http://www.traduc.org/mailman/listinfo/gnomefr",
+ "name": "fr",
+ "webpage_url": "http://gnomefr.traduc.org/",
+ "use_workflow": true,
+ "presentation": "Here can come any custom description for a team",
+ "mailing_list": "gnomefr traduc org",
+ "description": "French"
+ }
+ },
+ {
+ "pk": 2,
+ "model": "teams.team",
+ "fields": {
+ "mailing_list_subscribe": null,
+ "name": "it",
+ "webpage_url": "http://www.it.gnome.org/",
+ "use_workflow": true,
+ "presentation": "",
+ "mailing_list": null,
+ "description": "Italian"
+ }
+ },
+ {
+ "pk": 1,
+ "model": "teams.role",
+ "fields": {
+ "person": 1,
+ "role": "translator",
+ "team": 1
+ }
+ },
+ {
+ "pk": 2,
+ "model": "teams.role",
+ "fields": {
+ "person": 2,
+ "role": "coordinator",
+ "team": 1
+ }
+ },
+ {
+ "pk": 3,
+ "model": "teams.role",
+ "fields": {
+ "person": 3,
+ "role": "reviewer",
+ "team": 2
+ }
+ },
+ {
+ "pk": 1,
"model": "stats.module",
"fields": {
- "comment": "",
+ "comment": null,
"vcs_web": "http://git.gnome.org/browse/gnome-hello/",
"name": "gnome-hello",
"vcs_root": "git://git.gnome.org/gnome-hello",
- "bugs_product": "test",
+ "bugs_product": "gnome-hello",
"maintainers": [],
"bugs_component": "test",
"bugs_base": "http://bugzilla.gnome.org",
"vcs_type": "git",
- "homepage": "",
- "description": ""
+ "homepage": null,
+ "description": null
}
},
{
- "pk": 2,
+ "pk": 3,
"model": "stats.module",
"fields": {
"comment": "This is not a GNOME-specific module. Please submit your translation through the <a href=\"http://www.transifex.net/projects/p/shared-mime-info/c/default/\">Transifex platform</a>.",
@@ -67,12 +208,12 @@
"bugs_component": "general",
"bugs_base": "https://bugs.freedesktop.org/",
"vcs_type": "git",
- "homepage": "http://www.freedesktop.org/wiki/Software/shared-mime-info",
+ "homepage": null,
"description": "Shared MIME Info"
}
},
{
- "pk": 3,
+ "pk": 2,
"model": "stats.module",
"fields": {
"comment": null,
@@ -82,25 +223,25 @@
"bugs_product": "zenity",
"maintainers": [],
"bugs_component": "general",
- "bugs_base": "http://bugzilla.gnome.org/",
+ "bugs_base": "http://bugzilla.gnome.org",
"vcs_type": "git",
- "homepage": "",
- "description": "Zenity"
+ "homepage": null,
+ "description": null
}
},
{
- "pk": 1,
+ "pk": 2,
"model": "stats.branch",
"fields": {
"vcs_subpath": null,
"file_hashes": "",
"weight": 0,
- "name": "gnome-2-22",
- "module": 1
+ "name": "gnome-2-30",
+ "module": 2
}
},
{
- "pk": 2,
+ "pk": 1,
"model": "stats.branch",
"fields": {
"vcs_subpath": null,
@@ -125,7 +266,7 @@
"pk": 4,
"model": "stats.branch",
"fields": {
- "vcs_subpath": "",
+ "vcs_subpath": null,
"file_hashes": "",
"weight": 0,
"name": "master",
@@ -139,59 +280,59 @@
"name": "po",
"dtype": "ui",
"pot_method": null,
- "module": 3,
+ "module": 1,
"linguas_location": null,
"directory": "po",
- "description": "UI translations"
+ "description": "UI Translations"
}
},
{
- "pk": 2,
+ "pk": 3,
"model": "stats.domain",
"fields": {
"name": "po",
"dtype": "ui",
"pot_method": null,
- "module": 1,
+ "module": 2,
"linguas_location": null,
"directory": "po",
"description": "UI Translations"
}
},
{
- "pk": 3,
+ "pk": 5,
"model": "stats.domain",
"fields": {
"name": "po",
"dtype": "ui",
"pot_method": null,
- "module": 2,
+ "module": 3,
"linguas_location": null,
"directory": "po",
- "description": "UI translations"
+ "description": "UI Translations"
}
},
{
- "pk": 4,
+ "pk": 2,
"model": "stats.domain",
"fields": {
"name": "help",
"dtype": "doc",
"pot_method": null,
- "module": 3,
+ "module": 1,
"linguas_location": null,
"directory": "help",
"description": "User Guide"
}
},
{
- "pk": 5,
+ "pk": 4,
"model": "stats.domain",
"fields": {
"name": "help",
"dtype": "doc",
"pot_method": null,
- "module": 1,
+ "module": 2,
"linguas_location": null,
"directory": "help",
"description": "User Guide"
@@ -204,25 +345,36 @@
"name": "help",
"dtype": "doc",
"pot_method": null,
- "module": 2,
+ "module": 3,
"linguas_location": null,
"directory": "help",
"description": "User Guide"
}
},
{
- "pk": 1,
+ "pk": 2,
"model": "stats.release",
"fields": {
"status": "official",
"string_frozen": false,
- "name": "gnome-2-26",
+ "name": "gnome-dev",
"weight": 0,
- "description": "GNOME 2.26 (Development)"
+ "description": "GNOME in Development"
}
},
{
- "pk": 2,
+ "pk": 1,
+ "model": "stats.release",
+ "fields": {
+ "status": "official",
+ "string_frozen": true,
+ "name": "gnome-2-30",
+ "weight": 0,
+ "description": "GNOME 2.30 (stable)"
+ }
+ },
+ {
+ "pk": 3,
"model": "stats.release",
"fields": {
"status": "xternal",
@@ -236,18 +388,18 @@
"pk": 1,
"model": "stats.category",
"fields": {
- "release": 2,
- "name": "default",
- "branch": 3
+ "release": 1,
+ "name": "desktop",
+ "branch": 1
}
},
{
"pk": 2,
"model": "stats.category",
"fields": {
- "release": 1,
+ "release": 2,
"name": "desktop",
- "branch": 2
+ "branch": 1
}
},
{
@@ -256,6 +408,15 @@
"fields": {
"release": 1,
"name": "desktop",
+ "branch": 2
+ }
+ },
+ {
+ "pk": 4,
+ "model": "stats.category",
+ "fields": {
+ "release": 3,
+ "name": "desktop",
"branch": 4
}
},
@@ -263,13 +424,13 @@
"pk": 1,
"model": "stats.statistics",
"fields": {
- "domain": 3,
+ "domain": 1,
"language": null,
"num_figures": 0,
- "untranslated": 567,
+ "untranslated": 47,
"translated": 0,
- "branch": 3,
- "date": "2008-11-08 19:14:23",
+ "branch": 1,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -277,41 +438,41 @@
"pk": 2,
"model": "stats.statistics",
"fields": {
- "domain": 3,
+ "domain": 1,
"language": 2,
"num_figures": 0,
- "untranslated": 4,
- "translated": 546,
- "branch": 3,
- "date": "2008-11-07 15:41:43",
- "fuzzy": 17
+ "untranslated": 0,
+ "translated": 47,
+ "branch": 1,
+ "date": "2010-11-23 12:08:32",
+ "fuzzy": 0
}
},
{
"pk": 3,
"model": "stats.statistics",
"fields": {
- "domain": 3,
+ "domain": 1,
"language": 3,
"num_figures": 0,
- "untranslated": 17,
- "translated": 541,
- "branch": 3,
- "date": "2008-11-07 15:41:44",
- "fuzzy": 9
+ "untranslated": 7,
+ "translated": 30,
+ "branch": 1,
+ "date": "2010-11-23 12:08:32",
+ "fuzzy": 10
}
},
{
"pk": 4,
"model": "stats.statistics",
"fields": {
- "domain": 1,
+ "domain": 2,
"language": null,
- "num_figures": 0,
- "untranslated": 135,
+ "num_figures": 1,
+ "untranslated": 20,
"translated": 0,
- "branch": 2,
- "date": "2009-02-11 22:31:19",
+ "branch": 1,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -319,13 +480,13 @@
"pk": 5,
"model": "stats.statistics",
"fields": {
- "domain": 1,
+ "domain": 2,
"language": 2,
"num_figures": 0,
"untranslated": 0,
- "translated": 135,
- "branch": 2,
- "date": "2008-11-07 15:58:07",
+ "translated": 20,
+ "branch": 1,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -333,13 +494,13 @@
"pk": 6,
"model": "stats.statistics",
"fields": {
- "domain": 1,
+ "domain": 2,
"language": 3,
"num_figures": 0,
"untranslated": 0,
- "translated": 135,
- "branch": 2,
- "date": "2008-11-07 15:58:13",
+ "translated": 20,
+ "branch": 1,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -347,13 +508,13 @@
"pk": 7,
"model": "stats.statistics",
"fields": {
- "domain": 4,
+ "domain": 3,
"language": null,
- "num_figures": 11,
- "untranslated": 257,
+ "num_figures": 0,
+ "untranslated": 136,
"translated": 0,
"branch": 2,
- "date": "2009-02-11 22:31:20",
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -361,13 +522,13 @@
"pk": 8,
"model": "stats.statistics",
"fields": {
- "domain": 4,
+ "domain": 3,
"language": 2,
"num_figures": 0,
"untranslated": 0,
- "translated": 257,
+ "translated": 136,
"branch": 2,
- "date": "2009-02-11 22:21:30",
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -375,13 +536,13 @@
"pk": 9,
"model": "stats.statistics",
"fields": {
- "domain": 1,
- "language": null,
+ "domain": 3,
+ "language": 3,
"num_figures": 0,
- "untranslated": 130,
- "translated": 0,
- "branch": 1,
- "date": "2009-02-11 22:30:17",
+ "untranslated": 6,
+ "translated": 130,
+ "branch": 2,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -389,13 +550,13 @@
"pk": 10,
"model": "stats.statistics",
"fields": {
- "domain": 1,
- "language": 2,
- "num_figures": 0,
- "untranslated": 0,
- "translated": 130,
- "branch": 1,
- "date": "2009-02-11 22:29:53",
+ "domain": 4,
+ "language": null,
+ "num_figures": 11,
+ "untranslated": 259,
+ "translated": 0,
+ "branch": 2,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -403,13 +564,13 @@
"pk": 11,
"model": "stats.statistics",
"fields": {
- "domain": 1,
- "language": 3,
+ "domain": 4,
+ "language": 2,
"num_figures": 0,
- "untranslated": 0,
- "translated": 130,
- "branch": 1,
- "date": "2009-02-11 22:30:00",
+ "untranslated": 259,
+ "translated": 0,
+ "branch": 2,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -418,12 +579,12 @@
"model": "stats.statistics",
"fields": {
"domain": 4,
- "language": null,
- "num_figures": 11,
- "untranslated": 253,
- "translated": 0,
- "branch": 1,
- "date": "2009-02-11 22:30:18",
+ "language": 3,
+ "num_figures": 0,
+ "untranslated": 0,
+ "translated": 259,
+ "branch": 2,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -431,13 +592,13 @@
"pk": 13,
"model": "stats.statistics",
"fields": {
- "domain": 4,
- "language": 2,
+ "domain": 3,
+ "language": null,
"num_figures": 0,
- "untranslated": 0,
- "translated": 253,
- "branch": 1,
- "date": "2009-02-11 22:30:04",
+ "untranslated": 149,
+ "translated": 0,
+ "branch": 3,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -445,27 +606,27 @@
"pk": 14,
"model": "stats.statistics",
"fields": {
- "domain": 2,
- "language": null,
+ "domain": 3,
+ "language": 2,
"num_figures": 0,
- "untranslated": 47,
- "translated": 0,
- "branch": 4,
- "date": "2010-09-13 23:01:47",
- "fuzzy": 0
+ "untranslated": 0,
+ "translated": 255,
+ "branch": 3,
+ "date": "2010-11-23 12:08:32",
+ "fuzzy": 4
}
},
{
"pk": 15,
"model": "stats.statistics",
"fields": {
- "domain": 2,
- "language": 2,
+ "domain": 3,
+ "language": 3,
"num_figures": 0,
"untranslated": 0,
- "translated": 47,
- "branch": 4,
- "date": "2010-08-21 11:30:24",
+ "translated": 259,
+ "branch": 3,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -473,27 +634,27 @@
"pk": 16,
"model": "stats.statistics",
"fields": {
- "domain": 2,
- "language": 3,
- "num_figures": 0,
- "untranslated": 30,
- "translated": 9,
- "branch": 4,
- "date": "2010-08-21 11:30:25",
- "fuzzy": 8
+ "domain": 4,
+ "language": null,
+ "num_figures": 11,
+ "untranslated": 259,
+ "translated": 0,
+ "branch": 3,
+ "date": "2010-11-23 12:08:32",
+ "fuzzy": 0
}
},
{
"pk": 17,
"model": "stats.statistics",
"fields": {
- "domain": 5,
- "language": null,
- "num_figures": 1,
- "untranslated": 22,
+ "domain": 4,
+ "language": 2,
+ "num_figures": 0,
+ "untranslated": 259,
"translated": 0,
- "branch": 4,
- "date": "2010-09-13 23:01:47",
+ "branch": 3,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
@@ -501,187 +662,56 @@
"pk": 18,
"model": "stats.statistics",
"fields": {
- "domain": 5,
- "language": 2,
+ "domain": 4,
+ "language": 3,
"num_figures": 0,
"untranslated": 0,
- "translated": 22,
- "branch": 4,
- "date": "2010-08-21 11:30:31",
+ "translated": 259,
+ "branch": 3,
+ "date": "2010-11-23 12:08:32",
"fuzzy": 0
}
},
{
- "pk": 1,
- "model": "teams.team",
- "fields": {
- "mailing_list_subscribe": "http://www.traduc.org/mailman/listinfo/gnomefr",
- "name": "fr",
- "webpage_url": "http://gnomefr.traduc.org/",
- "use_workflow": true,
- "presentation": "Here can come any custom description for a team",
- "mailing_list": "gnomefr traduc org",
- "description": "French"
- }
- },
- {
- "pk": 2,
- "model": "teams.team",
- "fields": {
- "mailing_list_subscribe": null,
- "name": "it",
- "webpage_url": "http://www.it.gnome.org/",
- "use_workflow": true,
- "presentation": "",
- "mailing_list": null,
- "description": "Italian"
- }
- },
- {
- "pk": 1,
- "model": "teams.role",
- "fields": {
- "person": 2,
- "role": "translator",
- "team": 1
- }
- },
- {
- "pk": 2,
- "model": "teams.role",
- "fields": {
- "person": 4,
- "role": "coordinator",
- "team": 2
- }
- },
- {
- "pk": 3,
- "model": "teams.role",
- "fields": {
- "person": 3,
- "role": "coordinator",
- "team": 1
- }
- },
- {
- "pk": 1,
- "model": "vertimus.statedb",
+ "pk": 19,
+ "model": "stats.statistics",
"fields": {
"domain": 5,
- "name": "None",
- "language": 2,
- "updated": "2009-05-29 23:20:51",
- "person": null,
- "branch": 4
+ "language": null,
+ "num_figures": 0,
+ "untranslated": 626,
+ "translated": 0,
+ "branch": 4,
+ "date": "2010-11-23 12:08:32",
+ "fuzzy": 0
}
},
{
- "pk": 2,
- "model": "vertimus.statedb",
+ "pk": 20,
+ "model": "stats.statistics",
"fields": {
- "domain": 4,
- "name": "None",
+ "domain": 5,
"language": 2,
- "updated": "2009-06-16 19:53:36",
- "person": null,
- "branch": 2
- }
- },
- {
- "pk": 2,
- "model": "auth.user",
- "fields": {
- "username": "bob",
- "first_name": "Robert",
- "last_name": "Translator",
- "is_active": true,
- "is_superuser": false,
- "is_staff": false,
- "last_login": "2008-11-06 23:49:39",
- "groups": [],
- "user_permissions": [],
- "password": "sha1$4c846$3af94fa0135321db2ebc84866b323037028726ab",
- "email": "bob example org",
- "date_joined": "2008-11-06 23:49:39"
- }
- },
- {
- "pk": 3,
- "model": "auth.user",
- "fields": {
- "username": "coord_fr",
- "first_name": "French",
- "last_name": "Coordinator",
- "is_active": true,
- "is_superuser": false,
- "is_staff": false,
- "last_login": "2010-11-08 09:57:34",
- "groups": [],
- "user_permissions": [],
- "password": "sha1$0a578$c2f596f33f967c98bc5ed10ec48c490e3fe93199",
- "email": "coord_fr example org",
- "date_joined": "2008-11-06 23:49:39"
- }
- },
- {
- "pk": 4,
- "model": "auth.user",
- "fields": {
- "username": "coord_it",
- "first_name": "Alessio",
- "last_name": "Coordinator",
- "is_active": true,
- "is_superuser": false,
- "is_staff": false,
- "last_login": "2008-11-06 23:49:40",
- "groups": [],
- "user_permissions": [],
- "password": "sha1$52068$c609bd5b681c6818c91aeaa2a712043fa63b4306",
- "email": "alessio example org",
- "date_joined": "2008-11-06 23:49:40"
- }
- },
- {
- "pk": 2,
- "model": "people.person",
- "fields": {
- "bugzilla_account": "",
- "groups": [],
- "image": "",
- "activation_key": "",
- "irc_nick": "bobby",
- "svn_account": "bob1",
- "webpage_url": "",
- "user_permissions": []
- }
- },
- {
- "pk": 3,
- "model": "people.person",
- "fields": {
- "bugzilla_account": "",
- "groups": [],
- "image": "",
- "activation_key": "",
- "irc_nick": "",
- "svn_account": "coord_fr",
- "webpage_url": "",
- "user_permissions": []
+ "num_figures": 0,
+ "untranslated": 2,
+ "translated": 598,
+ "branch": 4,
+ "date": "2010-11-23 12:08:32",
+ "fuzzy": 20
}
},
{
- "pk": 4,
- "model": "people.person",
+ "pk": 21,
+ "model": "stats.statistics",
"fields": {
- "bugzilla_account": "",
- "groups": [],
- "image": "",
- "activation_key": "",
- "irc_nick": "",
- "svn_account": "",
- "webpage_url": "",
- "user_permissions": []
+ "domain": 5,
+ "language": 3,
+ "num_figures": 0,
+ "untranslated": 0,
+ "translated": 620,
+ "branch": 4,
+ "date": "2010-11-23 12:08:32",
+ "fuzzy": 6
}
}
-]
+]
\ No newline at end of file
diff --git a/stats/tests/__init__.py b/stats/tests/__init__.py
index b22f2bc..3c97730 100644
--- a/stats/tests/__init__.py
+++ b/stats/tests/__init__.py
@@ -30,6 +30,8 @@ from stats.models import Module, Domain, Branch, Category, Release, Statistics,
from stats.utils import check_program_presence
from languages.models import Language
+from fixture_factory import *
+
def test_scratchdir(test_func):
""" Decorator to temporarily use the scratchdir inside the test directory """
def decorator(self):
diff --git a/stats/tests/fixture_factory.py b/stats/tests/fixture_factory.py
new file mode 100644
index 0000000..2706fb7
--- /dev/null
+++ b/stats/tests/fixture_factory.py
@@ -0,0 +1,163 @@
+from tempfile import NamedTemporaryFile
+
+from django.core.management.commands.dumpdata import Command as Dumpdata
+from django.test import TestCase
+
+from languages.models import Language
+from teams.models import Team, Role
+from people.models import Person
+from stats.models import Module, Domain, Branch, Release, Category, Statistics
+
+class FixtureFactory(TestCase):
+ """ Fake Test case to create fixture.
+ To create a JSON fixture, run:
+ python manage.py test stats.FixtureFactory.make_fixture
+ """
+
+ def make_fixture(self):
+ # Creating models: Teams
+ t1 = Team(name='fr', description="French",
+ webpage_url="http://gnomefr.traduc.org/",
+ mailing_list="gnomefr traduc org",
+ mailing_list_subscribe="http://www.traduc.org/mailman/listinfo/gnomefr",
+ presentation="Here can come any custom description for a team")
+ t1.save()
+ t2 = Team(name='it', description="Italian",
+ webpage_url="http://www.it.gnome.org/")
+ t2.save()
+
+ # Creating models: Languages
+ l_en = Language(name='en', locale='en', plurals="nplurals=2; plural=(n != 1)")
+ l_en.save()
+ l_fr = Language(name='French', locale='fr', plurals="nplurals=2; plural=(n > 1)",
+ team=t1)
+ l_fr.save()
+ l_it = Language(name='Italian', locale='it', plurals="nplurals=2; plural=(n != 1)",
+ team=t2)
+ l_it.save()
+
+ # Creating models: Persons/Roles
+ p1 = Person(first_name='Robert', last_name='Translator',
+ email='bob example org', username='bob', irc_nick='bobby',
+ svn_account='bob1')
+ p1.save()
+ p1.set_password('bob')
+ r1 = Role(team=t1, person=p1, role='translator')
+ r1.save()
+ p2 = Person(first_name='John', last_name='Coordinator',
+ email='coord example org', username='coord', svn_account='coord_fr')
+ p2.save()
+ p2.set_password('coord')
+ r2 = Role(team=t1, person=p2, role='coordinator')
+ r2.save()
+ p3 = Person(first_name='Alessio', last_name='Reviewer',
+ email='alessio example org', username='alessio')
+ p3.save()
+ p1.set_password('alessio')
+ r3 = Role(team=t2, person=p3, role='reviewer')
+ r3.save()
+
+ # Creating models: Modules
+ gnome_hello = Module(name="gnome-hello", vcs_type="git",
+ vcs_root="git://git.gnome.org/gnome-hello",
+ vcs_web="http://git.gnome.org/browse/gnome-hello/",
+ bugs_base="http://bugzilla.gnome.org",
+ bugs_product="gnome-hello",
+ bugs_component="test")
+ gnome_hello.save()
+ zenity = Module(name="zenity", vcs_type="git",
+ vcs_root="git://git.gnome.org/zenity",
+ vcs_web="http://git.gnome.org/browse/zenity/",
+ bugs_base="http://bugzilla.gnome.org",
+ bugs_product="zenity",
+ bugs_component="general")
+ zenity.save()
+ s_m_i = Module(name="shared-mime-info", vcs_type="git",
+ description="Shared MIME Info",
+ vcs_root="git://anongit.freedesktop.org/xdg/shared-mime-info",
+ vcs_web="http://cgit.freedesktop.org/xdg/shared-mime-info/",
+ bugs_base="https://bugs.freedesktop.org/",
+ bugs_product="shared-mime-info",
+ bugs_component="general",
+ comment="This is not a GNOME-specific module. Please submit your translation " \
+ "through the <a href=\"http://www.transifex.net/projects/p/shared-mime-info/c/default/\">Transifex platform</a>.")
+ s_m_i.save()
+
+ # Creating models: Domains
+ dom = {}
+ for mod in (gnome_hello, zenity, s_m_i):
+ dom['%s-ui' % mod.name] = Domain(module=mod, name='po', description='UI Translations', dtype='ui', directory='po')
+ dom['%s-ui' % mod.name].save()
+ dom['%s-doc' % mod.name] = Domain(module=mod, name='help', description='User Guide', dtype='doc', directory='help')
+ dom['%s-doc' % mod.name].save()
+
+ # Creating models: Branches
+ Branch.checkout_on_creation = False
+ b1 = Branch(name='master', module=gnome_hello)
+ b1.save(update_statistics=False)
+ b2 = Branch(name='gnome-2-30', module=zenity)
+ b2.save(update_statistics=False)
+ b3 = Branch(name='master', module=zenity)
+ b3.save(update_statistics=False)
+ b4 = Branch(name='master', module=s_m_i)
+ b4.save(update_statistics=False)
+
+ # Creating models: Releases/Categories
+ rel1 = Release(name='gnome-2-30', status='official',
+ description='GNOME 2.30 (stable)',
+ string_frozen=True)
+ rel1.save()
+ rel2 = Release(name='gnome-dev', status='official',
+ description='GNOME in Development',
+ string_frozen=False)
+ rel2.save()
+ rel3 = Release(name='freedesktop-org', status='xternal',
+ description='freedesktop.org (non-GNOME)',
+ string_frozen=False)
+ rel3.save()
+
+ cat1 = Category(release=rel1, branch=b1, name='desktop')
+ cat1.save()
+ cat2 = Category(release=rel2, branch=b1, name='desktop')
+ cat2.save()
+ cat3 = Category(release=rel1, branch=b2, name='desktop')
+ cat3.save()
+ cat4 = Category(release=rel3, branch=b4, name='desktop')
+ cat4.save()
+
+ # Creating models: Statistics
+ # gnome-hello ui, gnome-hello doc (POT, fr, it)
+ stats = []
+ stats.append(Statistics(branch=b1, domain=dom['gnome-hello-ui'], language=None, untranslated=47))
+ stats.append(Statistics(branch=b1, domain=dom['gnome-hello-ui'], language=l_fr, translated=47))
+ stats.append(Statistics(branch=b1, domain=dom['gnome-hello-ui'], language=l_it, translated=30, fuzzy=10, untranslated=7))
+ stats.append(Statistics(branch=b1, domain=dom['gnome-hello-doc'], language=None, untranslated=20, num_figures=1))
+ stats.append(Statistics(branch=b1, domain=dom['gnome-hello-doc'], language=l_fr, translated=20))
+ stats.append(Statistics(branch=b1, domain=dom['gnome-hello-doc'], language=l_it, translated=20))
+ # zenity ui 2.30, zenity doc 2.30, zenity ui master, zenity doc master (POT, fr, it)
+ stats.append(Statistics(branch=b2, domain=dom['zenity-ui'], language=None, untranslated=136))
+ stats.append(Statistics(branch=b2, domain=dom['zenity-ui'], language=l_fr, translated=136))
+ stats.append(Statistics(branch=b2, domain=dom['zenity-ui'], language=l_it, translated=130, untranslated=6))
+ stats.append(Statistics(branch=b2, domain=dom['zenity-doc'], language=None, untranslated=259, num_figures=11))
+ stats.append(Statistics(branch=b2, domain=dom['zenity-doc'], language=l_fr, untranslated=259))
+ stats.append(Statistics(branch=b2, domain=dom['zenity-doc'], language=l_it, translated=259))
+ stats.append(Statistics(branch=b3, domain=dom['zenity-ui'], language=None, untranslated=149))
+ stats.append(Statistics(branch=b3, domain=dom['zenity-ui'], language=l_fr, translated=255, fuzzy=4))
+ stats.append(Statistics(branch=b3, domain=dom['zenity-ui'], language=l_it, translated=259))
+ stats.append(Statistics(branch=b3, domain=dom['zenity-doc'], language=None, untranslated=259, num_figures=11))
+ stats.append(Statistics(branch=b3, domain=dom['zenity-doc'], language=l_fr, untranslated=259))
+ stats.append(Statistics(branch=b3, domain=dom['zenity-doc'], language=l_it, translated=259))
+ # shared-mime-info ui (POT, fr, it)
+ stats.append(Statistics(branch=b4, domain=dom['shared-mime-info-ui'], language=None, untranslated=626))
+ stats.append(Statistics(branch=b4, domain=dom['shared-mime-info-ui'], language=l_fr, translated=598, fuzzy=20, untranslated=2))
+ stats.append(Statistics(branch=b4, domain=dom['shared-mime-info-ui'], language=l_it, translated=620, fuzzy=6))
+ for st in stats:
+ st.save()
+
+ # Output fixture
+ data = Dumpdata().handle(*['auth.User', 'people', 'languages', 'teams', 'stats'],
+ **{'indent':1})
+ out_file = NamedTemporaryFile(suffix=".json", dir=".", delete=False)
+ out_file.write(data)
+ out_file.close()
+ print "Fixture created in the file %s" % out_file.name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]