Exemplo n.º 1
0
 def setUp(self):
     self.value = "good"
     self.confidence = 0.42
     self.full = RepoPrediction(
         confidence=self.confidence, value=self.value
     )
     self.null = RepoPrediction()
Exemplo n.º 2
0
class TestRepoPrediction(unittest.TestCase):
    def setUp(self):
        self.value = "good"
        self.confidence = 0.42
        self.full = RepoPrediction(
            confidence=self.confidence, value=self.value
        )
        self.null = RepoPrediction()

    def test_full_property_confidence(self):
        self.assertEqual(self.confidence, self.full["confidence"])
        self.assertEqual(self.full.confidence, self.full["confidence"])

    def test_full_property_value(self):
        self.assertEqual(self.value, self.full["value"])
        self.assertEqual(self.full.value, self.full["value"])

    def test_full_dict_returns_self(self):
        self.assertEqual(self.full, self.full.dict())

    def test_full_len_2(self):
        self.assertEqual(2, len(self.full))

    def test_full_bool_true(self):
        self.assertTrue(self.full)

    def test_null_dict_empty_array(self):
        self.assertEqual([], self.null.dict())

    def test_null_len_0(self):
        self.assertEqual(0, len(self.null))

    def test_null_bool_false(self):
        self.assertFalse(self.null)
Exemplo n.º 3
0
 def setUp(self):
     self.confidence = 0.42
     self.classification = "good"
     self.full = RepoPrediction(
         confidence=self.confidence, classification=self.classification
     )
     self.null = RepoPrediction()
Exemplo n.º 4
0
 def test_str(self):
     self.full.prediction = RepoPrediction()
     self.assertIn("Undetermined", str(self.full))
     self.full.data.prediction = RepoPrediction(value="Good")
     self.assertIn("Good", str(self.full))
     self.full.extra.update(dict(hi=5))
     self.assertIn("5", str(self.full))
     self.full.extra = dict()
     self.assertNotIn("5", str(self.full))
Exemplo n.º 5
0
 def test_str(self):
     self.full.prediction = RepoPrediction()
     self.assertIn('Undetermined', str(self.full))
     self.full.data.prediction = RepoPrediction(classification='Good')
     self.assertIn('Good', str(self.full))
     self.full.data.classification = 'Great'
     self.assertIn('Great', str(self.full))
     self.full.extra.update(dict(hi=5))
     self.assertIn('5', str(self.full))
     self.full.extra = dict()
     self.assertNotIn('5', str(self.full))
Exemplo n.º 6
0
class TestRepoPrediction(unittest.TestCase):

    def setUp(self):
        self.confidence = 0.42
        self.classification = 'good'
        self.full = RepoPrediction(confidence=self.confidence,
                classification=self.classification)
        self.null = RepoPrediction()

    def test_full_property_confidence(self):
        self.assertEqual(self.confidence, self.full['confidence'])
        self.assertEqual(self.full.confidence,
                self.full['confidence'])

    def test_full_property_classification(self):
        self.assertEqual(self.classification, self.full['classification'])
        self.assertEqual(self.full.classification,
                self.full['classification'])

    def test_full_dict_returns_self(self):
        self.assertEqual(self.full, self.full.dict())

    def test_full_len_2(self):
        self.assertEqual(2, len(self.full))

    def test_full_bool_true(self):
        self.assertTrue(self.full)

    def test_null_dict_empty_array(self):
        self.assertEqual([], self.null.dict())

    def test_null_len_0(self):
        self.assertEqual(0, len(self.null))

    def test_null_bool_false(self):
        self.assertFalse(self.null)