def test_parse_value(self):
        runner = parse_value("runner", '["UraniumAnchor"]')
        self.assertTrue(runner.id)
        self.assertEqual(runner.name, "UraniumAnchor")

        event = models.Event.objects.create(date=datetime.date.today(), targetamount=5, short="agdq2015")
        self.assertEqual(parse_value("event", '["agdq2015"]'), event)
        run = parse_value("run", '["Mega Man 3", ["agdq2015"]]')
        self.assertTrue(run.id)
        self.assertEqual(run.name, "Mega Man 3")
        self.assertEqual(run.event, event)

        self.assertEqual(parse_value("FAKE_FIELD", "FAKE_VALUE"), "FAKE_VALUE")
    def test_parse_value(self):
        runner = parse_value('runner', '["UraniumAnchor"]')
        self.assertTrue(runner.id)
        self.assertEqual(runner.name, 'UraniumAnchor')

        event = models.Event.objects.create(
            date=datetime.date.today(), targetamount=5, short='agdq2015')
        self.assertEqual(parse_value('event', '["agdq2015"]'), event)
        run = parse_value('run', '["Mega Man 3", ["agdq2015"]]')
        self.assertTrue(run.id)
        self.assertEqual(run.name, 'Mega Man 3')
        self.assertEqual(run.event, event)

        self.assertEqual(parse_value('FAKE_FIELD', 'FAKE_VALUE'), 'FAKE_VALUE')
예제 #3
0
 def test_m2m_natural_key_full_json_fetch(self):
     expected_runners = [self.runner1, self.runner2]
     runners = parse_value(
         models.SpeedRun,
         'runners',
         json.dumps([r.natural_key() for r in expected_runners]),
     )
     self.assertEqual(runners, expected_runners)
예제 #4
0
 def test_complex_natural_key_as_json_create(self):
     run = parse_value(
         models.Bid,
         'speedrun',
         '["Mega Man 3", ["%s"]]' % self.event.short,
         self.super_user,
     )
     self.assertTrue(run.id)
     self.assertEqual(run.name, 'Mega Man 3')
     self.assertEqual(run.event, self.event)
예제 #5
0
 def test_m2m_natural_key_csv_bad_fetch(self):
     with self.assertRaises(models.Runner.DoesNotExist):
         parse_value(models.SpeedRun, 'runners', 'total,nonsense')
예제 #6
0
 def test_m2m_natural_key_csv_fetch(self):
     expected_runners = [self.runner1, self.runner2]
     runners = parse_value(models.SpeedRun, 'runners',
                           ','.join(r.name for r in expected_runners))
     self.assertEqual(runners, expected_runners)
예제 #7
0
 def test_m2m_pk_json_bad_fetch(self):
     with self.assertRaises(models.Runner.DoesNotExist):
         parse_value(models.SpeedRun, 'runners', '[1001,1002]')
예제 #8
0
 def test_m2m_pk_json_fetch(self):
     expected_runners = [self.runner1, self.runner2]
     runners = parse_value(models.SpeedRun, 'runners',
                           json.dumps([r.pk for r in expected_runners]))
     self.assertEqual(runners, expected_runners)
예제 #9
0
 def test_m2m_pk_csv_fetch(self):
     expected_runners = [self.runner1, self.runner2]
     runners = parse_value(models.SpeedRun, 'runners',
                           ','.join(str(r.pk) for r in expected_runners))
     self.assertEqual(runners, expected_runners)
예제 #10
0
 def test_single_natural_key_as_json_create(self):
     runner = parse_value(models.Submission, 'runner', '["UraniumAnchor"]',
                          self.super_user)
     self.assertTrue(runner.id)
     self.assertEqual(runner.name, 'UraniumAnchor')
예제 #11
0
 def test_single_natural_key_as_json_fetch(self):
     self.assertEqual(
         parse_value(models.SpeedRun, 'event',
                     json.dumps(self.event.natural_key())),
         self.event,
     )
예제 #12
0
 def test_single_natural_key_as_string_fetch(self):
     self.assertEqual(
         parse_value(models.SpeedRun, 'event', self.event.short),
         self.event)
예제 #13
0
 def test_single_pk_as_string_fetch(self):
     self.assertEqual(
         parse_value(models.SpeedRun, 'event', str(self.event.pk)),
         self.event)
예제 #14
0
 def test_m2m_natural_key_full_json_bad_fetch(self):
     with self.assertRaises(models.Runner.DoesNotExist):
         parse_value(models.SpeedRun, 'runners', '[["total"],["nonsense"]]')