import os
import sys
from rhcephcompose import main


class FakeCompose(object):
    def run(self):
        pass


class ComposeRecorder(object):
    """ Record the arg to the Compose object's constructor. """
    def __call__(self, conf):
        self.conf = conf
        return FakeCompose()


class TestMain(object):

    def test_constructor(self, fixtures_dir, monkeypatch):
        conf = os.path.join(fixtures_dir, 'basic.conf')
        monkeypatch.setattr(sys, 'argv', ['rhcephcompose', conf])
        recorder = ComposeRecorder()
        monkeypatch.setattr(main, 'Compose', recorder)
        main.RHCephCompose()
        expected = {
            'builds': {'trusty': 'builds-ceph-2.0-trusty.txt',
                       'xenial': 'builds-ceph-2.0-xenial.txt'},
            'chacra_url': 'https://chacra.example.com/',
            'compose_type': 'test',
            'comps': {'trusty': 'comps-basic.xml'},
            'extra_files': [{'file': 'README'}, {'file': 'EULA'},
                            {'file': 'GPL'}],
            'product_version': '2',
            'target': 'trees',
            'variants_file': 'variants-basic.xml'
        }
        assert recorder.conf == expected

@@ -45,16 +45,124 @@
 rt main%0A
+import pytest%0A%0A%0A@pytest.fixture%0Adef conf(fixtures_dir):%0A    return os.path.join(fixtures_dir, 'basic.conf')%0A
 %0A%0Aclass 
@@ -453,28 +453,20 @@
 r(self, 
-fixtures_dir
+conf
 , monkey
@@ -477,64 +477,8 @@
 h):%0A
-        conf = os.path.join(fixtures_dir, 'basic.conf')%0A
     

use conf fixture for test_main.py