Skip to content

Commit

Permalink
changed default values for analysisstatus
Browse files Browse the repository at this point in the history
  • Loading branch information
stuhli committed Nov 26, 2020
1 parent 35759c7 commit 437ea68
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
class SystemImporterFileCsvConfigbasedConfigFormTestCase(TestCase):
""" system importer file CSV config-based config form tests """

@classmethod
def setUpTestData(cls):

# create object
Analysisstatus.objects.create(analysisstatus_name = 'analysisstatus_1')


def test_system_importer_file_csv_config_based_config_csv_skip_existing_system_form_label(self):
""" test form label """

Expand Down Expand Up @@ -203,7 +210,7 @@ def test_system_importer_file_csv_config_based_config_form_analysisstatus_filled
""" test minimum form requirements / INVALID """

# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='Needs analysis').analysisstatus_id
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='analysisstatus_1').analysisstatus_id
# get object
form = SystemImporterFileCsvConfigbasedConfigForm(data = {
'csv_default_analysisstatus': analysisstatus_id,
Expand All @@ -219,7 +226,7 @@ def test_system_importer_file_csv_config_based_config_form_same_columns(self):
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
systemstatus_id = Systemstatus.objects.get(systemstatus_name='Unknown').systemstatus_id
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='Needs analysis').analysisstatus_id
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='analysisstatus_1').analysisstatus_id
# get object
form = SystemImporterFileCsvConfigbasedConfigForm(data = {
'csv_default_systemstatus': systemstatus_id,
Expand All @@ -236,7 +243,7 @@ def test_system_importer_file_csv_config_based_config_form_different_columns(sel
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
systemstatus_id = Systemstatus.objects.get(systemstatus_name='Unknown').systemstatus_id
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='Needs analysis').analysisstatus_id
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='analysisstatus_1').analysisstatus_id
# get object
form = SystemImporterFileCsvConfigbasedConfigForm(data = {
'csv_default_systemstatus': systemstatus_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def setUpTestData(cls):
# create user
User.objects.create_user(username='testuser_system_importer_file_csv_config_based_config', password='sBH771ZCj2Y5rjfCPtVC')

# create object
Analysisstatus.objects.create(analysisstatus_name='analysisstatus_1')

def test_system_importer_file_csv_config_based_config_not_logged_in(self):
""" test importer view """

Expand Down Expand Up @@ -72,7 +75,7 @@ def test_system_importer_file_csv_config_based_config_post_redirect(self):
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
systemstatus_id = Systemstatus.objects.get(systemstatus_name='Unknown').systemstatus_id
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='Needs analysis').analysisstatus_id
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='analysisstatus_1').analysisstatus_id
# create post data
data_dict = {
'csv_default_systemstatus': systemstatus_id,
Expand All @@ -93,7 +96,7 @@ def test_system_importer_file_csv_config_based_config_post_invalid_reload(self):
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
systemstatus_id = Systemstatus.objects.get(systemstatus_name='Unknown').systemstatus_id
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='Needs analysis').analysisstatus_id
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='analysisstatus_1').analysisstatus_id
# create post data
data_dict = {
'csv_default_systemstatus': systemstatus_id,
Expand All @@ -114,7 +117,7 @@ def test_system_importer_file_csv_config_based_config_post_invalid_template(self
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
systemstatus_id = Systemstatus.objects.get(systemstatus_name='Unknown').systemstatus_id
# get object (does not work the usual way because form with available choices is build before model instance is created during the test)
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='Needs analysis').analysisstatus_id
analysisstatus_id = Analysisstatus.objects.get(analysisstatus_name='analysisstatus_1').analysisstatus_id
# create post data
data_dict = {
'csv_default_systemstatus': systemstatus_id,
Expand Down
8 changes: 4 additions & 4 deletions dfirtrack_main/migrations/0002_default_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class Migration(migrations.Migration):

operations = [

migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('Needs analysis');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('Ready for analysis');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('Ongoing analysis');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('Nothing to do');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('10_needs_analysis');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('20_ready_for_analysis');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('30_ongoing_analysis');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('40_nothing_to_do');"),

migrations.RunSQL("INSERT INTO dfirtrack_main_headline (headline_name) VALUES ('Summary');"),

Expand Down
2 changes: 1 addition & 1 deletion dfirtrack_main/migrations/0007_systemstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Migration(migrations.Migration):

migrations.RunSQL("INSERT INTO dfirtrack_main_systemstatus (systemstatus_name) VALUES ('Not analyzed');"),

migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('Main analysis finished');"),
migrations.RunSQL("INSERT INTO dfirtrack_main_analysisstatus (analysisstatus_name) VALUES ('50_main_analysis_finished');"),

]
8 changes: 4 additions & 4 deletions dfirtrack_main/tests/system/test_system_creator_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ def test_system_creator_post_systems(self):

# login testuser
self.client.login(username='testuser_system_creator', password='Jbf5fZBhpg1aZsCW6L8r')
# get objects
analysisstatus_needs_analysis = Analysisstatus.objects.get(analysisstatus_name = 'Needs analysis')
# create objects
analysisstatus_1 = Analysisstatus.objects.create(analysisstatus_name = 'analysisstatus_1')
systemstatus_unknown = Systemstatus.objects.get(systemstatus_name = 'Unknown')
# create post data
data_dict = {
'systemlist': 'system_creator_system_1\nsystem_creator_system_2\nsystem_creator_system_3\n\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nsystem_creator_duplicate_system',
'analysisstatus': analysisstatus_needs_analysis.analysisstatus_id,
'analysisstatus': analysisstatus_1.analysisstatus_id,
'systemstatus': systemstatus_unknown.systemstatus_id,
}
# get response
Expand All @@ -115,6 +115,6 @@ def test_system_creator_post_systems(self):
self.assertTrue(System.objects.filter(system_name='system_creator_system_2').exists())
self.assertTrue(System.objects.filter(system_name='system_creator_system_3').exists())
self.assertFalse(System.objects.filter(system_name='system_creator_system_4').exists())
self.assertEqual(System.objects.get(system_name='system_creator_system_1').analysisstatus, analysisstatus_needs_analysis)
self.assertEqual(System.objects.get(system_name='system_creator_system_1').analysisstatus, analysisstatus_1)
self.assertEqual(System.objects.get(system_name='system_creator_system_1').systemstatus, systemstatus_unknown)
self.assertEqual(System.objects.filter(system_name='system_creator_duplicate_system').count(), 1)

0 comments on commit 437ea68

Please sign in to comment.