def mock_sequence_diagram(self, has_fragment, has_multiple_fragments): sequence_diagram = SequenceDiagram(name='SequenceDiagram', guard_condition=True) # LifeLines lifelines = {0 : Lifeline(id=0, name='LifeLineX')} sequence_diagram.set_life_lines(lifelines) # Message message = Message(name='MensagemX', source=lifelines[0], target=lifelines[0], prob=0.5, message_type='Synchronous') sequence_diagram.set_messages(message) if has_fragment: fragment = Fragment(name='Fragment1', represented_by=sequence_diagram.name, sequence_diagram=sequence_diagram) sequence_diagram.set_fragments(fragment) if has_multiple_fragments: fragment = Fragment(name='Fragment2', represented_by=sequence_diagram.name, sequence_diagram=self.mock_sequence_diagram(False, False)) sequence_diagram.set_fragments(fragment) if has_fragment: sequence_diagram.get_fragments()[0].sequence_diagram = sequence_diagram return sequence_diagram
def put_fragment(wikia_name, title): if request.content_type != 'application/json': response.status = 400 response.body = "Only Content-Type: application/json is permitted for this resource" return response if request.json is None: response.status = 400 response.body = "invalid json in request" return response db_connection = get_connection(CONFIG) wikia = Wikia() try: wikia.load_by_name(db_connection, wikia_name) except WikiaNotFoundException: response.status = 404 response.body = "Wikia not found" return response fragment = Fragment() try: fragment.init_from_data(db_connection, wikia, title, request.json) except FragmentIncompleteException: response.status = 400 response.body = "Incomplete fragment data given for PUT" return response fragment.save(db_connection) response.status = 201 response.headers['Location'] = request.url return response
class TestActivityDiagram(unittest.TestCase): def setUp(self): self.fragment = Fragment() @parameterized.expand([ ['Diagrama 1'], ['Diagrama 2'], ['Diagrama 3'], ]) def test_set_represented_by(self, represented_by): self.fragment.set_represented_by(represented_by) self.assertEqual(self.fragment.get_represented_by(), represented_by)
def add_fragment(sequence_diagram_name=None): fragment_name = input('Insert the Fragment name: ') if sequence_diagram_name != None: diagram_name = sequence_diagram_name sequence_diagram = None else: diagram_name = input('Insert the Sequence Diagram name: ') print('Create the Sequence Diagram that is represented by the fragment ' + fragment_name) sequence_diagram = create_sequence_diagram(diagram_name) sequence_diagram.set_fragments(Fragment(name=fragment_name, represented_by=diagram_name)) sequence_diagram = sequence_diagram_menu(sequence_diagram) fragment = Fragment(name=fragment_name, represented_by=diagram_name, sequence_diagram=sequence_diagram) return fragment
def delete_fragment(wikia_name, title): db_connection = get_connection(CONFIG) wikia = Wikia() try: wikia.load_by_name(db_connection, wikia_name) except WikiaNotFoundException: response.status = 200 return response fragment = Fragment() try: fragment.load_by_title(db_connection, wikia, title) except FragmentNotFoundException: response.status = 200 return response fragment.delete(db_connection) response.status = 204 return response
def get_article(wikia_name, title): db_connection = get_connection(CONFIG) wikia = Wikia() try: wikia.load_by_name(db_connection, wikia_name) except WikiaNotFoundException: response.status = 404 response.body = "Wikia not found" return response fragment = Fragment() try: fragment.load_by_title(db_connection, wikia, title) except FragmentNotFoundException: response.status = 404 response.body = "Fragment not found" return response view = FragmentView(fragment) return view.render_json()
def setUp(self): self.fragment = Fragment()