Пример #1
0
    def delete(self, secondary_id):
        secondary = SecondaryModel.from_id(secondary_id)
        if secondary is None:
            abort(400, "That secondary does not exist.")

        system = secondary.system_key.get()

        if not Owner.is_owner_of(current_user, system):
            abort(401)

        secondaries = SecondaryModel.from_system(system)
        if secondary in secondaries:
            secondaries.remove(secondary)
        ret = self.get_response_map_from_secondaries(secondaries)

        try:
            secondary.key.delete()
        except AttributeError:
            pass

        return jsonify(ret)
Пример #2
0
def test_from_id(random_secondary):
    id_ = random_secondary.key.integer_id()

    assert Secondary.from_id(id_) == random_secondary