diff --git a/README.md b/README.md
index 341c749..323ce02 100644
--- a/README.md
+++ b/README.md
@@ -60,11 +60,11 @@ PROJECT STRUCTURE:
--------------------------------------------------------------------------------------------
CURRENT VERSION
-Date: 20/06/2016
+Date: 22/06/2016
By: Paul Carensac
-Version: 0.7.6
-Colors + buttons submit on request list, and fixed a redirection bug in request building
-Issues (closed): https://projects.irap.omp.eu/issues/3838
+Version: 0.7.7
+Tests for Alert, User and Routine Managers
+Issues (closed): https://projects.irap.omp.eu/issues/3833
Major current version (0.7): https://projects.irap.omp.eu/versions/117
ROADMAP: https://projects.irap.omp.eu/projects/pyros/roadmap
diff --git a/src/alert_manager/strategies/strat_unittest.xml b/src/alert_manager/strategies/strat_unittest.xml
new file mode 100644
index 0000000..b28212b
--- /dev/null
+++ b/src/alert_manager/strategies/strat_unittest.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/alert_manager/tasks.py b/src/alert_manager/tasks.py
index fb8b35c..c0dc65a 100644
--- a/src/alert_manager/tasks.py
+++ b/src/alert_manager/tasks.py
@@ -155,7 +155,7 @@ class alert_listener(Task):
sequences = [sequence.strip('\n') for sequence in sequences]
request_builder = RequestBuilder()
- request_builder.start_new_request(PyrosUser.objects.get(), ScientificProgram.objects.get(), True, name="Simulation_request")
+ request_builder.start_new_request(PyrosUser.objects.all()[0], ScientificProgram.objects.all()[0], True, name="Simulation_request")
for sequence in sequences:
sequence_array = sequence.split(" ")
id_seq = sequence_array[0]
diff --git a/src/alert_manager/tests.py b/src/alert_manager/tests.py
index 8724678..ab08274 100644
--- a/src/alert_manager/tests.py
+++ b/src/alert_manager/tests.py
@@ -15,7 +15,50 @@ TEST_FILE_PATH = os.path.join(alert_manager.tasks.VOEVENTS_PATH, TEST_FILE)
VOEVENTS_TO_SEND_PATH = "alert_manager/events_to_send"
-class AlertListenerTests(TestCase):
+class TestStrategyChange(TestCase):
+
+ fixtures = ['alert_mgr_test.json']
+
+ def setUp(self):
+ '''
+ Creates the base for the tests
+ '''
+
+ self.alert = Alert.objects.get()
+ self.strat1 = Alert.objects.get().strategyobs
+ self.strat2 = StrategyObs.objects.exclude(id=self.strat1.id)[0]
+ self.alert.strategyobs = self.strat1
+ self.alert.save()
+
+ def test_change_inexistant_strat(self):
+ self.client.login(username="test@test.test", password="test")
+ path = "/alert_manager/change_obs_strategy_validate/" + str(self.alert.id)
+ response = self.client.post(path, {"strategy_choice": 42})
+ self.assertTrue("error" in response.context.keys(), "There should be an error of non existant strategy")
+
+ def test_change_inexistant_alert(self):
+ self.client.login(username="test@test.test", password="test")
+ path = "/alert_manager/change_obs_strategy_validate/" + str(self.alert.id + 1)
+ response = self.client.post(path, {"strategy_choice": self.strat2.id})
+ self.assertTrue("error" in response.context.keys(), "There should be an error of non existant alert")
+
+ def test_change_same_strat(self):
+ self.client.login(username="test@test.test", password="test")
+ path = "/alert_manager/change_obs_strategy_validate/" + str(self.alert.id)
+ response = self.client.post(path, {"strategy_choice": self.strat1.id})
+ self.assertTrue("error" in response.context.keys(), "There should be an error of changing to same strategy")
+
+ def test_change_all_working(self):
+ self.client.login(username="test@test.test", password="test")
+ path = "/alert_manager/change_obs_strategy_validate/" + str(self.alert.id)
+ response = self.client.post(path, {"strategy_choice": self.strat2.id})
+ self.assertFalse("error" in response.context.keys(), "There shouldn't be an error")
+ self.assertEqual(Alert.objects.count(), 2, "There should be 2 alerts after the strategy change")
+ new_alert = Alert.objects.exclude(id=self.alert.id)[0]
+ self.assertEqual(new_alert.strategyobs.id, self.strat2.id, "The new alert should have the 'strat2' strategy")
+
+
+class AlertListenerTestsCelery(TestCase):
def setup(self):
pass
diff --git a/src/alert_manager/views.py b/src/alert_manager/views.py
index 5520621..ca14e22 100644
--- a/src/alert_manager/views.py
+++ b/src/alert_manager/views.py
@@ -58,9 +58,18 @@ def change_obs_strategy_validate(request, alert_id):
'''
Creates a new request with the strategy given for the selected alert
'''
- alert = Alert.objects.get(id=alert_id)
+
+ try:
+ alert = Alert.objects.get(id=alert_id)
+ except Exception:
+ alerts = Alert.objects.all()
+ error = True
+ message = "This alert doesn't exist"
+ return render(request, "alert_manager/alerts.html", locals())
+
strategies = StrategyObs.objects.exclude(id=alert.strategyobs.id)
if request.method == "POST":
+
strategy_id = request.POST["strategy_choice"]
try:
strategy = StrategyObs.objects.get(id=strategy_id)
@@ -69,16 +78,7 @@ def change_obs_strategy_validate(request, alert_id):
message = "This strategy doesn't exist"
return render(request, "alert_manager/strategy_change.html", locals())
- try:
- alert = Alert.objects.get(id=alert_id)
- except Exception:
- error = True
- message = "This alert doesn't exist"
- return render(request, "alert_manager/strategy_change.html", locals())
-
- print(alert.strategyobs.id, strategy_id)
-
- if alert.strategyobs.id == strategy_id:
+ if str(alert.strategyobs.id) == strategy_id:
error = True
message = "This is already the current strategy for this alert"
return render(request, "alert_manager/strategy_change.html", locals())
@@ -97,4 +97,5 @@ def change_obs_strategy_validate(request, alert_id):
success = True
message = "Strategy successfully changed. A new request was created."
+
return render(request, "alert_manager/strategy_change.html", locals())
diff --git a/src/common/RequestBuilder.py b/src/common/RequestBuilder.py
index 9d373ac..9fb69c9 100644
--- a/src/common/RequestBuilder.py
+++ b/src/common/RequestBuilder.py
@@ -41,12 +41,8 @@ class RequestBuilder():
This function MUST be called to build a request.
It erases the previous one, and creates the sequences', albums' and plans' dictionaries.
'''
- if settings.SIMULATION == False:
- self.request = Request(name=name,
- scientific_program=scientific_program, pyros_user=pyros_user, is_alert=is_alert, complete=True, submitted=True)
- else:
- self.request = Request(name=name, scientific_program=ScientificProgram.objects.get(
- ), pyros_user=PyrosUser.objects.get(), is_alert=True, complete=True, submitted=True)
+ self.request = Request(name=name,
+ scientific_program=scientific_program, pyros_user=pyros_user, is_alert=is_alert, complete=True, submitted=True)
self.sequence_id = 1
self.album_id = 1
self.plan_id = 1
diff --git a/src/fixtures/alert_mgr_test.json b/src/fixtures/alert_mgr_test.json
new file mode 100644
index 0000000..e09e26f
--- /dev/null
+++ b/src/fixtures/alert_mgr_test.json
@@ -0,0 +1,342 @@
+[
+{
+ "model": "pyrosapp.country",
+ "pk": 1,
+ "fields": {
+ "name": "France",
+ "desc": "",
+ "quota": null
+ }
+},
+{
+ "model": "pyrosapp.detector",
+ "pk": 1,
+ "fields": {
+ "device": 1,
+ "telescope": 1,
+ "status": "",
+ "nb_photo_x": null,
+ "nb_photo_y": null,
+ "photo_size_x": null,
+ "photo_size_y": null,
+ "has_shutter": false,
+ "equivalent_foc_len": "",
+ "acq_start": null,
+ "acq_stop": null,
+ "check_temp": null,
+ "gain": null,
+ "readout_noise": null,
+ "readout_time": null,
+ "idcam_readout_mode": null
+ }
+},
+{
+ "model": "pyrosapp.detector",
+ "pk": 2,
+ "fields": {
+ "device": 7,
+ "telescope": 1,
+ "status": "",
+ "nb_photo_x": null,
+ "nb_photo_y": null,
+ "photo_size_x": null,
+ "photo_size_y": null,
+ "has_shutter": false,
+ "equivalent_foc_len": "",
+ "acq_start": null,
+ "acq_stop": null,
+ "check_temp": null,
+ "gain": null,
+ "readout_noise": null,
+ "readout_time": null,
+ "idcam_readout_mode": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 1,
+ "fields": {
+ "name": "Cagire",
+ "desc": "",
+ "created": "2016-05-13T11:49:49.663Z",
+ "updated": "2016-05-13T11:49:49.664Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 2,
+ "fields": {
+ "name": "First infrared filter",
+ "desc": "",
+ "created": "2016-05-13T11:49:56.579Z",
+ "updated": "2016-05-13T11:49:56.579Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 3,
+ "fields": {
+ "name": "First visible filter",
+ "desc": "",
+ "created": "2016-05-13T11:50:02.012Z",
+ "updated": "2016-05-13T11:50:02.013Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 4,
+ "fields": {
+ "name": "Second infrared filter",
+ "desc": "",
+ "created": "2016-05-13T11:50:07.592Z",
+ "updated": "2016-05-13T11:50:07.592Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 5,
+ "fields": {
+ "name": "Second visible filter",
+ "desc": "",
+ "created": "2016-05-13T11:50:11.226Z",
+ "updated": "2016-05-13T11:50:11.226Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 6,
+ "fields": {
+ "name": "Telescope",
+ "desc": "",
+ "created": "2016-05-13T11:50:14.326Z",
+ "updated": "2016-05-13T11:50:14.326Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 7,
+ "fields": {
+ "name": "Visible camera",
+ "desc": "",
+ "created": "2016-05-13T11:50:17.644Z",
+ "updated": "2016-05-13T11:50:17.644Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 1,
+ "fields": {
+ "device": 2,
+ "detector": 1,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 2,
+ "fields": {
+ "device": 4,
+ "detector": 1,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 3,
+ "fields": {
+ "device": 3,
+ "detector": 2,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 4,
+ "fields": {
+ "device": 5,
+ "detector": 2,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.scientificprogram",
+ "pk": 1,
+ "fields": {
+ "name": "GRB",
+ "desc": "",
+ "quota": 9999.0,
+ "priority": 0,
+ "pyros_users": [
+ 1
+ ]
+ }
+},
+{
+ "model": "pyrosapp.strategyobs",
+ "pk": 1,
+ "fields": {
+ "name": "strat1",
+ "desc": "",
+ "xml_file": "strat1.xml"
+ }
+},
+{
+ "model": "pyrosapp.strategyobs",
+ "pk": 2,
+ "fields": {
+ "name": "strat2",
+ "desc": "",
+ "xml_file": "strat2.xml"
+ }
+},
+{
+ "model": "pyrosapp.telescope",
+ "pk": 1,
+ "fields": {
+ "device": 6,
+ "mount_type": "",
+ "diameter": null,
+ "status": "",
+ "latitude": null,
+ "longitude": null,
+ "sens": "",
+ "altitude": null,
+ "readout_time": null,
+ "slew_time": null,
+ "slew_dead": null,
+ "slew_rate_max": null,
+ "horizon_type": "",
+ "horizon_def": null,
+ "lim_dec_max": null,
+ "lim_dec_min": null,
+ "lim_ha_rise": null,
+ "lim_ha_set": null,
+ "address": "",
+ "night_elev_sun": null,
+ "mpc_code": ""
+ }
+},
+{
+ "model": "pyrosapp.userlevel",
+ "pk": 1,
+ "fields": {
+ "name": "Developer",
+ "desc": "",
+ "priority": 0,
+ "quota": 9999.0
+ }
+},
+{
+ "model": "auth.user",
+ "pk": 8,
+ "fields": {
+ "password": "pbkdf2_sha256$24000$bKJO902RCk0w$zxUz9uiSYG85ymuvl5rNLLqT/LZwrLwpVj5WfwwSyKE=",
+ "last_login": "2016-06-21T13:07:34.383Z",
+ "is_superuser": false,
+ "username": "test@test.test",
+ "first_name": "test",
+ "last_name": "test",
+ "email": "test@test.test",
+ "is_staff": false,
+ "is_active": true,
+ "date_joined": "2016-06-21T13:07:19.609Z",
+ "groups": [],
+ "user_permissions": []
+ }
+},
+{
+ "model": "pyrosapp.pyrosuser",
+ "pk": 3,
+ "fields": {
+ "user": 8,
+ "country": 1,
+ "user_level": 1,
+ "desc": null,
+ "created": "2016-06-21T13:07:19.911Z",
+ "updated": "2016-06-21T13:07:19.911Z",
+ "tel": "test",
+ "address": "test",
+ "laboratory": "test",
+ "last_connect": null,
+ "cur_connect": null,
+ "putvalid_beg": null,
+ "putvalid_end": null,
+ "acqvalid_beg": null,
+ "acqvalid_end": null,
+ "quota": null,
+ "quota_rea": null,
+ "u_priority": null,
+ "p_priority": null,
+ "dir_level": null,
+ "can_del_void_req": false
+ }
+},{
+ "model": "pyrosapp.alert",
+ "pk": 8,
+ "fields": {
+ "request": 65,
+ "strategyobs": 1,
+ "voevent_xml": null,
+ "type": null,
+ "client": null,
+ "burst_jd": null,
+ "burst_ra": null,
+ "burst_dec": null,
+ "equinox": null,
+ "jd_pkt": null,
+ "jd_send": null,
+ "jd_received": null,
+ "trigger_instrum": null,
+ "trigger_num": null,
+ "grb_error": null,
+ "def_not_grb": false,
+ "editor": null,
+ "flag": null,
+ "idgcn_notice": null
+ }
+},{
+ "model": "pyrosapp.request",
+ "pk": 65,
+ "fields": {
+ "pyros_user": 3,
+ "scientific_program": 1,
+ "name": "Simulation_request",
+ "desc": null,
+ "created": "2016-06-21T12:51:24.293Z",
+ "updated": "2016-06-21T12:51:24.293Z",
+ "is_alert": true,
+ "target_type": null,
+ "status": null,
+ "autodeposit": false,
+ "checkpoint": null,
+ "flag": null,
+ "complete": true,
+ "submitted": true
+ }
+}
+]
diff --git a/src/fixtures/routine_mgr_test.json b/src/fixtures/routine_mgr_test.json
new file mode 100644
index 0000000..f6933d2
--- /dev/null
+++ b/src/fixtures/routine_mgr_test.json
@@ -0,0 +1,380 @@
+[
+{
+ "model": "pyrosapp.country",
+ "pk": 1,
+ "fields": {
+ "name": "France",
+ "desc": "",
+ "quota": null
+ }
+},
+{
+ "model": "pyrosapp.detector",
+ "pk": 1,
+ "fields": {
+ "device": 1,
+ "telescope": 1,
+ "status": "",
+ "nb_photo_x": null,
+ "nb_photo_y": null,
+ "photo_size_x": null,
+ "photo_size_y": null,
+ "has_shutter": false,
+ "equivalent_foc_len": "",
+ "acq_start": null,
+ "acq_stop": null,
+ "check_temp": null,
+ "gain": null,
+ "readout_noise": null,
+ "readout_time": null,
+ "idcam_readout_mode": null
+ }
+},
+{
+ "model": "pyrosapp.detector",
+ "pk": 2,
+ "fields": {
+ "device": 7,
+ "telescope": 1,
+ "status": "",
+ "nb_photo_x": null,
+ "nb_photo_y": null,
+ "photo_size_x": null,
+ "photo_size_y": null,
+ "has_shutter": false,
+ "equivalent_foc_len": "",
+ "acq_start": null,
+ "acq_stop": null,
+ "check_temp": null,
+ "gain": null,
+ "readout_noise": null,
+ "readout_time": null,
+ "idcam_readout_mode": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 1,
+ "fields": {
+ "name": "Cagire",
+ "desc": "",
+ "created": "2016-05-13T11:49:49.663Z",
+ "updated": "2016-05-13T11:49:49.664Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 2,
+ "fields": {
+ "name": "First infrared filter",
+ "desc": "",
+ "created": "2016-05-13T11:49:56.579Z",
+ "updated": "2016-05-13T11:49:56.579Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 3,
+ "fields": {
+ "name": "First visible filter",
+ "desc": "",
+ "created": "2016-05-13T11:50:02.012Z",
+ "updated": "2016-05-13T11:50:02.013Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 4,
+ "fields": {
+ "name": "Second infrared filter",
+ "desc": "",
+ "created": "2016-05-13T11:50:07.592Z",
+ "updated": "2016-05-13T11:50:07.592Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 5,
+ "fields": {
+ "name": "Second visible filter",
+ "desc": "",
+ "created": "2016-05-13T11:50:11.226Z",
+ "updated": "2016-05-13T11:50:11.226Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 6,
+ "fields": {
+ "name": "Telescope",
+ "desc": "",
+ "created": "2016-05-13T11:50:14.326Z",
+ "updated": "2016-05-13T11:50:14.326Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.device",
+ "pk": 7,
+ "fields": {
+ "name": "Visible camera",
+ "desc": "",
+ "created": "2016-05-13T11:50:17.644Z",
+ "updated": "2016-05-13T11:50:17.644Z",
+ "is_online": false,
+ "status": "",
+ "maintenance_date": null
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 1,
+ "fields": {
+ "device": 2,
+ "detector": 1,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 2,
+ "fields": {
+ "device": 4,
+ "detector": 1,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 3,
+ "fields": {
+ "device": 3,
+ "detector": 2,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.filter",
+ "pk": 4,
+ "fields": {
+ "device": 5,
+ "detector": 2,
+ "category": "",
+ "transmission_curve_doc": ""
+ }
+},
+{
+ "model": "pyrosapp.scientificprogram",
+ "pk": 1,
+ "fields": {
+ "name": "GRB",
+ "desc": "",
+ "quota": 9999.0,
+ "priority": 0,
+ "pyros_users": [
+ 1
+ ]
+ }
+},
+{
+ "model": "pyrosapp.strategyobs",
+ "pk": 1,
+ "fields": {
+ "name": "strat1",
+ "desc": "",
+ "xml_file": "strat1.xml"
+ }
+},
+{
+ "model": "pyrosapp.strategyobs",
+ "pk": 2,
+ "fields": {
+ "name": "strat2",
+ "desc": "",
+ "xml_file": "strat2.xml"
+ }
+},
+{
+ "model": "pyrosapp.telescope",
+ "pk": 1,
+ "fields": {
+ "device": 6,
+ "mount_type": "",
+ "diameter": null,
+ "status": "",
+ "latitude": null,
+ "longitude": null,
+ "sens": "",
+ "altitude": null,
+ "readout_time": null,
+ "slew_time": null,
+ "slew_dead": null,
+ "slew_rate_max": null,
+ "horizon_type": "",
+ "horizon_def": null,
+ "lim_dec_max": null,
+ "lim_dec_min": null,
+ "lim_ha_rise": null,
+ "lim_ha_set": null,
+ "address": "",
+ "night_elev_sun": null,
+ "mpc_code": ""
+ }
+},
+{
+ "model": "pyrosapp.userlevel",
+ "pk": 1,
+ "fields": {
+ "name": "Developer",
+ "desc": "",
+ "priority": 0,
+ "quota": 9999.0
+ }
+},
+{
+ "model": "auth.user",
+ "pk": 8,
+ "fields": {
+ "password": "pbkdf2_sha256$24000$bKJO902RCk0w$zxUz9uiSYG85ymuvl5rNLLqT/LZwrLwpVj5WfwwSyKE=",
+ "last_login": "2016-06-21T13:07:34.383Z",
+ "is_superuser": false,
+ "username": "test@test.test",
+ "first_name": "test",
+ "last_name": "test",
+ "email": "test@test.test",
+ "is_staff": false,
+ "is_active": true,
+ "date_joined": "2016-06-21T13:07:19.609Z",
+ "groups": [],
+ "user_permissions": []
+ }
+},
+{
+ "model": "pyrosapp.pyrosuser",
+ "pk": 3,
+ "fields": {
+ "user": 8,
+ "country": 1,
+ "user_level": 1,
+ "desc": null,
+ "created": "2016-06-21T13:07:19.911Z",
+ "updated": "2016-06-21T13:07:19.911Z",
+ "tel": "test",
+ "address": "test",
+ "laboratory": "test",
+ "last_connect": null,
+ "cur_connect": null,
+ "putvalid_beg": null,
+ "putvalid_end": null,
+ "acqvalid_beg": null,
+ "acqvalid_end": null,
+ "quota": null,
+ "quota_rea": null,
+ "u_priority": null,
+ "p_priority": null,
+ "dir_level": null,
+ "can_del_void_req": false
+ }
+},{
+ "model": "pyrosapp.request",
+ "pk": 66,
+ "fields": {
+ "pyros_user": 3,
+ "scientific_program": 1,
+ "name": "Simulation_request_strat2",
+ "desc": null,
+ "created": "2016-06-21T13:42:04.493Z",
+ "updated": "2016-06-22T12:34:09.401Z",
+ "is_alert": true,
+ "target_type": "dqsd",
+ "status": null,
+ "autodeposit": false,
+ "checkpoint": null,
+ "flag": null,
+ "complete": true,
+ "submitted": false
+ }
+},
+{
+ "model": "pyrosapp.sequence",
+ "pk": 53,
+ "fields": {
+ "request": 66,
+ "name": "Simulation_request_strat2_0",
+ "desc": null,
+ "created": "2016-06-21T13:42:04.587Z",
+ "updated": "2016-06-22T12:32:16.892Z",
+ "is_alert": false,
+ "status": "CPL",
+ "target_coords": "sdfghj",
+ "with_drift": false,
+ "priority": 0,
+ "analysis_method": null,
+ "moon_min": null,
+ "alt_min": null,
+ "type": null,
+ "img_current": null,
+ "img_total": null,
+ "not_obs": false,
+ "obsolete": false,
+ "processing": false,
+ "flag": null,
+ "jd1": "0E-8",
+ "jd2": "9000000.00000000",
+ "t_prefered": "-1.00000000",
+ "duration": "0.00023148",
+ "overhead": "0E-8"
+ }
+},
+{
+ "model": "pyrosapp.album",
+ "pk": 55,
+ "fields": {
+ "sequence": 53,
+ "detector": 2,
+ "name": "Simulation_request_strat2_01",
+ "desc": null,
+ "created": "2016-06-21T13:42:04.874Z",
+ "updated": "2016-06-22T12:32:16.787Z",
+ "complete": true
+ }
+},
+{
+ "model": "pyrosapp.plan",
+ "pk": 58,
+ "fields": {
+ "album": 55,
+ "filter": 3,
+ "name": "Simulation_request_strat2_010",
+ "desc": null,
+ "created": "2016-06-21T13:42:05.309Z",
+ "updated": "2016-06-22T12:32:16.690Z",
+ "duration": 0.0002314814814814815,
+ "position": null,
+ "exposure_time": null,
+ "nb_images": 1,
+ "dithering": false,
+ "complete": true
+ }
+}
+]
diff --git a/src/routine_manager/templates/routine_manager/requests_list.html b/src/routine_manager/templates/routine_manager/requests_list.html
index 00e9e59..9cf5302 100644
--- a/src/routine_manager/templates/routine_manager/requests_list.html
+++ b/src/routine_manager/templates/routine_manager/requests_list.html
@@ -40,7 +40,7 @@
-
+
1000000:
+ if file is None:
+ status = -1
+ message = "File does not exist"
+ elif file.size > 1000000:
status = -1
message = "File is too big (more than 1 000 000 bytes)"
else:
diff --git a/src/saved_requests/request63.xml b/src/saved_requests/request63.xml
new file mode 100644
index 0000000..364631b
--- /dev/null
+++ b/src/saved_requests/request63.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/saved_requests/request66.xml b/src/saved_requests/request66.xml
new file mode 100644
index 0000000..45aa019
--- /dev/null
+++ b/src/saved_requests/request66.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/src/user_manager/templates/user_manager/home_user_creation.html b/src/user_manager/templates/user_manager/home_user_creation.html
index 0adf187..d98ba97 100644
--- a/src/user_manager/templates/user_manager/home_user_creation.html
+++ b/src/user_manager/templates/user_manager/home_user_creation.html
@@ -20,7 +20,7 @@
{% for field in form %}
-
+
{{ field }}
{{ field.errors }}
diff --git a/src/user_manager/tests.py b/src/user_manager/tests.py
index 7ce503c..054e667 100644
--- a/src/user_manager/tests.py
+++ b/src/user_manager/tests.py
@@ -1,3 +1,64 @@
from django.test import TestCase
+from pyrosapp.models import *
+from django.contrib.auth.models import User
-# Create your tests here.
+from pprint import pprint
+
+class UserManagerTests(TestCase):
+
+ def setUp(self):
+ UserLevel.objects.create()
+ Country.objects.create()
+
+ def test_creation(self):
+ path = "/user_manager/creation_validate"
+ response = self.client.post(path, {"email": "toto@titi.fr", "password": "aze", "password_confirm": "aze",
+ "first_name": "toto", "last_name": "titi", "tel": "0123456789",
+ "laboratory": "IRAP", "address": "ici"})
+ self.assertTrue("success" in response.context.keys(), "There should be a success")
+ self.assertEqual(User.objects.count(), 1, "There should be one User")
+ self.assertEqual(PyrosUser.objects.count(), 1, "There should be one PyrosUser")
+
+ def test_login(self):
+ path = "/user_manager/creation_validate"
+ response = self.client.post(path, {"email": "toto@titi.fr", "password": "aze", "password_confirm": "aze",
+ "first_name": "toto", "last_name": "titi", "tel": "0123456789",
+ "laboratory": "IRAP", "address": "ici"})
+
+ path = "/user_manager/login"
+ response = self.client.post(path, {"email": "toto@titi.fr", "password": "aze"})
+
+ """ Note that we use .has_key() because the login phase change the httpresponse context """
+ self.assertTrue(response.context.has_key("success"), "There should be a success")
+ self.assertIn('_auth_user_id', self.client.session, "The user should be logged in")
+
+ def test_wrong_email(self):
+ path = "/user_manager/creation_validate"
+ response = self.client.post(path, {"email": "toto@titi.fr", "password": "aze", "password_confirm": "aze",
+ "first_name": "toto", "last_name": "titi", "tel": "0123456789",
+ "laboratory": "IRAP", "address": "ici"})
+
+ path = "/user_manager/login"
+ response = self.client.post(path, {"email": "toto@tti.fr", "password": "aze"})
+ self.assertIn("error", response.context.keys(), "There should be an error")
+ self.assertNotIn('_auth_user_id', self.client.session, "There shouldn't be an authentified user")
+
+ def test_wrong_password(self):
+ path = "/user_manager/creation_validate"
+ response = self.client.post(path, {"email": "toto@titi.fr", "password": "aze", "password_confirm": "aze",
+ "first_name": "toto", "last_name": "titi", "tel": "0123456789",
+ "laboratory": "IRAP", "address": "ici"})
+ path = "/user_manager/login"
+ response = self.client.post(path, {"email": "toto@titi.fr", "password": "azee"})
+ self.assertIn("error", response.context.keys(), "There should be an error")
+ self.assertNotIn('_auth_user_id', self.client.session, "There shouldn't be an authentified user")
+
+ def test_logout(self):
+ path = "/user_manager/creation_validate"
+ response = self.client.post(path, {"email": "toto@titi.fr", "password": "aze", "password_confirm": "aze",
+ "first_name": "toto", "last_name": "titi", "tel": "0123456789",
+ "laboratory": "IRAP", "address": "ici"})
+ self.client.login(username="toto@titi.fr", password="aze")
+ path = "/user_manager/logout"
+ self.client.get(path)
+ self.assertNotIn('_auth_user_id', self.client.session, "There shouldn't be an authentified user")
--
libgit2 0.21.2