コード例 #1
0
    def test_rangeconstraints_GET(self):
        httpRcs = RangeConstraints(self.req)
        self.req.swagger_data = {'appid': 1, 'ckid': 2}
        response = httpRcs.rangeconstraints_GET()

        expected = RangeConstraint.query().filter(
            RangeConstraint.configurationkey_id == 2)
        expected = list(map(lambda _: _.as_dict(), expected))

        assert response == expected
コード例 #2
0
 def test_rangecontraints_POST(self):
     self.req.swagger_data = {
         'appid': 1,
         'ckid': 2,
         'rangeconstraint': RangeConstraint(operator_id=4, value=10)
     }
     httpCkeys = RangeConstraints(self.req)
     response = httpCkeys.rangecontraints_POST()
     rc = RangeConstraint.query()\
         .filter(RangeConstraint.configurationkey_id == 2,
             RangeConstraint.operator_id==4,
             RangeConstraint.value==10)\
         .one().as_dict()
     assert response == rc
コード例 #3
0
    def test_rangeconstraints_POST_is_valid_value(self):
        expected_count = RangeConstraint.query().count()
        self.req.swagger_data = {
            'appid': 1,
            'ckid': 2,
            'rangeconstraint': RangeConstraint(operator_id=2,
                                               value="Herpiderp")
        }
        httpCkeys = RangeConstraints(self.req)
        response = httpCkeys.rangecontraints_POST()

        expected_status = 400
        count_now = RangeConstraint.query().count()

        assert count_now == expected_count
        assert response.status_code == expected_status
コード例 #4
0
 def test_rangeconstraints_for_configuratinkey_DELETE(self):
     self.req.swagger_data = {'appid': 1, 'ckid': 2}
     httpRcs = RangeConstraints(self.req)
     response = httpRcs.rangeconstraints_for_configuratinkey_DELETE()
     assert len(
         ConfigurationKey.get(2).rangeconstraints) == 0 and response == {}
コード例 #5
0
 def test_rangecontraints_DELETE_one_nonexistent(self):
     self.req.swagger_data = {'appid': 1, 'ckid': 2, 'rcid': 3}
     httpRcs = RangeConstraints(self.req)
     response = httpRcs.rangecontraints_DELETE_one()
     assert response.status_code == 400
コード例 #6
0
 def test_rangecontraints_DELETE_one(self):
     self.req.swagger_data = {'appid': 1, 'ckid': 1, 'rcid': 1}
     httpRcs = RangeConstraints(self.req)
     response = httpRcs.rangecontraints_DELETE_one()
     assert response == {}
コード例 #7
0
 def test_rangeconstraints_GET_with_incorrect_confkeyid(self):
     self.req.swagger_data = {'appid': 1, 'ckid': 42}
     httpRcs = RangeConstraints(self.req)
     response = httpRcs.rangeconstraints_GET()
     assert response == []
コード例 #8
0
 def test_rangeconstraints_for_configuratinkey_DELETE_incorrect_confkey_id(
         self):
     self.req.swagger_data = {'appid': 1, 'ckid': 3}
     httpRcs = RangeConstraints(self.req)
     response = httpRcs.rangeconstraints_for_configuratinkey_DELETE()
     assert response.status_code == 400